home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / util1 / yk211src.lha / Yak_2.11_Src / Prefs / Convert / Hotkey_Naming.c < prev    next >
C/C++ Source or Header  |  1995-11-16  |  2KB  |  129 lines

  1. /*
  2. ** This file contains functions to give name to hotkey converted
  3. ** from Yak 1.x to Yak 2.x
  4. */
  5.  
  6.  
  7.  
  8.  
  9. #include <exec/types.h>
  10. #include <ctype.h>
  11. #include <libraries/commodities.h>
  12.  
  13. #include "code.h"
  14. #include "yak.h"
  15. #include "hotkey_types.h"
  16. #include "hotkey_naming.h"
  17.  
  18. #define CATCOMP_BLOCK
  19. #define CATCOMP_NUMBERS
  20. #include "locale/yak_locale_strings.h"
  21. #undef CATCOMP_BLOCK
  22.  
  23. #define MAX_LENGTH_NAME 100
  24.  
  25. static char NewName[100];
  26.  
  27. void
  28. ColorUp (char *I_Str, char *O_Str)
  29. {
  30.     UBYTE n = 0;
  31.     BOOL  FirstWord = TRUE;
  32.  
  33.     while ((*I_Str != '\0') && (n < MAX_LENGTH_NAME-1))
  34.     {
  35.         if ((*I_Str == ' ') || (FirstWord == TRUE))
  36.         {
  37.             while ((*I_Str != '\0') && (*I_Str == ' '))
  38.             {
  39.                 /* Skip white space */
  40.                 ++I_Str;
  41.             };
  42.  
  43.             /* Capitalize first char after white space */
  44.             if (*I_Str != '\0')
  45.             {
  46.                 *O_Str = toupper(*I_Str);
  47.                 ++O_Str;
  48.                 n++;
  49.  
  50.                 FirstWord = FALSE;
  51.             } 
  52.  
  53.         }
  54.         else
  55.         { 
  56.             /* Copy other chars */
  57.             *O_Str = *I_Str;
  58.             ++O_Str;
  59.         }
  60.  
  61.         if (*I_Str != '\0')
  62.         {
  63.             ++I_Str;
  64.             n++;
  65.         }
  66.     }
  67.     *O_Str = '\0';
  68. }
  69.  
  70.  
  71.  
  72. void
  73. FirstWord (char *I_Str, char *O_Str)
  74. {
  75.     UBYTE n = 0;
  76.  
  77.     while ((*I_Str != '\0') && (*I_Str == ' ') && (n < MAX_LENGTH_NAME-1))
  78.     {
  79.         /* Skip white space */
  80.         ++I_Str;
  81.     };
  82.  
  83.     /* Capitalize first char after white space */
  84.     if (*I_Str != '\0')
  85.     {
  86.         *O_Str = toupper(*I_Str);
  87.         ++O_Str;
  88.         ++I_Str;
  89.         n++;
  90.     } 
  91.  
  92.     while ((*I_Str != '\0') &&  (*I_Str != ' ') && (n < MAX_LENGTH_NAME-1))
  93.     { 
  94.         /* Copy other chars */
  95.         *O_Str = *I_Str;
  96.         ++O_Str;
  97.         ++I_Str;
  98.         n++;
  99.     }
  100.  
  101.     *O_Str = '\0';
  102.     ++O_Str;
  103. }
  104.  
  105.  
  106. void 
  107. AutomaticNaming (YakHotKey *yhk)
  108. {
  109.     switch(yhk->yhk_Type)
  110.     {
  111.       case EXECUTE_COMMAND:
  112.         /* Name will be generated from the command to execute */
  113.         FirstWord(yhk->yhk_Option[1].ArgStr[0], NewName);
  114.         break;
  115.  
  116.       case INSERT_TEXT:
  117.         /* Name will be generated from the text to insert */
  118.         ColorUp(yhk->yhk_Option[0].ArgStr[0], NewName);
  119.         break;
  120.  
  121.       default:
  122.         /* Name will be generated from the localized name of the action */
  123.         ColorUp(getString(yhktypes[yhk->yhk_Type].yhkt_nameID), NewName);
  124.         break;
  125.     }
  126.  
  127.     ModifyYHKName(yhk, NewName);
  128. }
  129.